<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\node\model;

class RoleAdmin extends \app\BaseModel
{
    protected $name = "massage_role_admin";
    public function dataAdd($data)
    {
        $res = $this->insert($data);
        return $res;
    }
    public function dataUpdate($dis, $data)
    {
        $res = $this->where($dis)->update($data);
        return $res;
    }
    public function dataList($dis, $page)
    {
        $data = $this->where($dis)->order("status desc,id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataInfo($dis)
    {
        $data = $this->where($dis)->find();
        return !empty($data) ? $data->toArray() : [];
    }
    public function getUserAuth($user_id)
    {
        $dis = ["b.status" => 1, "a.admin_id" => $user_id];
        $data = $this->alias("a")->join("massage_role_list b", "a.role_id = b.id")->join("massage_role_node c", "c.role_id = b.id")->where($dis)->field("c.*")->group("c.id")->select()->toArray();
        if(!empty($data)) {
            foreach ($data as $k => $v) {
                $data[$k]["auth"] = !empty($v["auth"]) ? explode(",", $v["auth"]) : [];
            }
        }
        return $data;
    }
    public function getUserRole($user_id, $uniacid)
    {
        $dis = ["a.uniacid" => $uniacid, "b.status" => 1, "a.admin_id" => $user_id];
        $data = $this->alias("a")->join("massage_role_list b", "a.role_id = b.id")->where($dis)->field("b.*,a.role_id")->group("b.id")->column("b.id");
        return $data;
    }
}

?>